<?php

require_once("class/student.class.php");

?>

<div class="listing-container">

<table class="session-listing" border="0" cellspacing="0">

 <tr>
  <th width="160px">Name</th>
  <th width="160px">Description</th>
  <th width="160px">Session Start</th>
  <th width="160px">Duration</th>
  <th width="160px">Tutor</th>
  <th width="160px" colspan="2">Enrollment</th>
 </tr>

 <?php 
  
  $account_row = NULL;
  $tutorials = student::getInstance()->get_available_sessions();
  if ($tutorials) {
   while (($tutorial_row = mysql_fetch_array($tutorials, MYSQL_ASSOC)) != NULL) {
 ?>
 
  <tr id="session_<?php echo $tutorial_row['session_id'] ?>">
   <td><?php echo $tutorial_row['name'] ?></td>
   <td><?php echo $tutorial_row['description'] ?></td>
   <td><?php echo $tutorial_row['starttime'] ?></td>
   <td><?php echo $tutorial_row['duration'] ?></td>
   <td><?php echo $tutorial_row['firstname'] ?></td>
   <td><?php 
        $no_enrollments = student::getInstance()->get_session_enrollment($tutorial_row['session_id']);
        $no_enrollments = mysql_fetch_assoc($no_enrollments);
        $no_enrollments = $no_enrollments["COUNT(*)"];
    
   echo $no_enrollments . "/" . $tutorial_row['max_student'] ?></td>
   <td><a href="#" title="Enroll" class="enrl"><img src="img/icon_plus.png" alt="Enroll"></td>
  </tr>

 <?php 
  }
 }
 ?>
 
</table>

</div>